import java.util.Arrays;
import java.util.LinkedList;

public class test {
    public static void main(String[] args) {
        test test = new test();
        int[] nums={5,1,1,2,0,0};
        System.out.println(Arrays.toString(test.sortArray(nums)));
    }
    public int[] sortArray(int[] nums) {
        int n=nums.length;
        LinkedList<Integer> list = new LinkedList<>();
        list.add(nums[0]);
        for (int i = 1; i < n; i++) {
            int size = list.size();
            for (int j = size-1; j >=0; j--) {
                if (nums[i]>=list.get(j)){
                    list.add(j+1,nums[i]);
                    break;
                }
                else if(j==0&&nums[i]<list.get(j)) {
                    list.add(0,nums[i]);
                }
            }
        }
        int[] nums1 = new int[n];
        int index=0;
        for (Integer k:list) {
            nums1[index++]=k;
        }
        return nums1;
    }
}

